Allow custom interpolation patterns for placeholders#319
Allow custom interpolation patterns for placeholders#319voldy wants to merge 1 commit intoruby-i18n:masterfrom
Conversation
|
This will break backwards compatibility for anyone who uses |
But if you do not do this I18n.config.interpolation_patterns << /\{\{(\w+)\}\}/nothing is changed for you. This is do not break compatibility. Or I miss something? |
|
Agree with @stereobooster. @radar, I do not see any clue that this pull request will break compatibility; instead, @voldy handles backward compatibility very well and makes it customizable, so there is no need to keep pending this feature until v1.0. |
|
@voldy looks like this has a merge conflict now |
add a new config: `I18n.config.interpolation_patterns`
Usage:
I18n.config.interpolation_patterns << /\{\{(\w+)\}\}/
I18n.interpolate("Hello, {{name}}", name: "tonytonyjan")
# => "Hello, tonytonyjan"
close ruby-i18n#319
add a new config: `I18n.config.interpolation_patterns`
Usage:
I18n.config.interpolation_patterns << /\{\{(\w+)\}\}/
I18n.interpolate("Hello, {{name}}", name: "tonytonyjan")
# => "Hello, tonytonyjan"
close ruby-i18n#319
|
opened #439 as an improved version of this pull request. |
|
Closing this as #439 is more up-to-date. |
Pain
In our project we use
%{foo}placeholders for rails back end translations and{{foo}}for ember client. In some cases we need the same translation both at back end and front end which is a pain to support the same translations only because of different interpolation placeholders.Solution
I added an ability to configure custom interpolation patterns in i18n so that different placeholders can be used: